﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BI.CF.BLL;
using BI.CF.Model;
using BI.CF.PageList;

namespace BackStage
{
    public partial class SelectMomLoanMone : System.Web.UI.Page
    {
        MemLoanBLL bll = new MemLoanBLL();
        Pager<MemLoanModel> page = new Pager<MemLoanModel>();
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                showMone();
            }
        }
        public void showMone()
        {
            string Title = Title1.Text;
            string MinTime = "";
            string MaxTime = "";
            string State = "";
            int Usid = 0;
            string ss = this.MinTime1.Text;
            if (MinTime1.Text == "")
            {
                MinTime = "1700-1-1";
            }
            else
            {
                MinTime = MinTime1.Text;
            }
            if (MaxTime1.Text == "")
            {
                MaxTime="1700-1-1";
            }
            else
            {
                MaxTime = MaxTime1.Text;
            }
            AspNetPager1.PageSize = 10;
            page = bll.SelectMomLoanMone(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex,Title, MinTime, MaxTime, State, Usid);
            AspNetPager1.RecordCount = page.PageCount;
            Repeater1.DataSource = page.Data;
            Repeater1.DataBind();
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int id =Convert.ToInt32(e.CommandArgument);
            string name = e.CommandName;
            if (name=="ok")
            {
                bll.UpdateMemloanState(id, 2);
                Response.Write("<script>alert('审核通过')</script>");
                showMone();
                
            }
            if (name=="pas")
            {
                bll.UpdateMemloanState(id,1);
                Response.Write("<script>alert('驳回审核')</script>");
                showMone();
            }
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            string Title = Title1.Text;
            string MinTime = "";
            string MaxTime = "";
            string State = "";
            int Usid = 0;
            string ss = this.MinTime1.Text;
            if (MinTime1.Text == "")
            {
                MinTime = "1700-1-1";
            }
            else
            {
                MinTime = MinTime1.Text;
            }
            if (MaxTime1.Text == "")
            {
                MaxTime = "1700-1-1";
            }
            else
            {
                MaxTime = MaxTime1.Text;
            }
            AspNetPager1.PageSize = 5;
            AspNetPager1.CurrentPageIndex = 1;
            page = bll.SelectMomLoanMone(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, Title, MinTime, MaxTime, State, Usid);
            AspNetPager1.RecordCount = page.PageCount;
            Repeater1.DataSource = page.Data;
            Repeater1.DataBind();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            showMone();
        }
    }
}